/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.vportal.portlet.edirectory.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import com.vportal.portlet.edirectory.model.EDFunctionEmployee;
import com.vportal.portlet.edirectory.model.EDFunctionEmployeeModel;
import com.vportal.portlet.edirectory.model.EDFunctionEmployeeSoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.List;

/**
 * The base model implementation for the EDFunctionEmployee service. Represents a row in the &quot;EDFunctionEmployee&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.vportal.portlet.edirectory.model.EDFunctionEmployeeModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link EDFunctionEmployeeImpl}.
 * </p>
 *
 * @author HOAN
 * @see EDFunctionEmployeeImpl
 * @see com.vportal.portlet.edirectory.model.EDFunctionEmployee
 * @see com.vportal.portlet.edirectory.model.EDFunctionEmployeeModel
 * @generated
 */
@JSON(strict = true)
public class EDFunctionEmployeeModelImpl extends BaseModelImpl<EDFunctionEmployee>
	implements EDFunctionEmployeeModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a e d function employee model instance should use the {@link com.vportal.portlet.edirectory.model.EDFunctionEmployee} interface instead.
	 */
	public static final String TABLE_NAME = "EDFunctionEmployee";
	public static final Object[][] TABLE_COLUMNS = {
			{ "uuid_", Types.VARCHAR },
			{ "id_", Types.BIGINT },
			{ "functionId", Types.BIGINT },
			{ "employeeId", Types.BIGINT }
		};
	public static final String TABLE_SQL_CREATE = "create table EDFunctionEmployee (uuid_ VARCHAR(75) null,id_ LONG not null primary key,functionId LONG,employeeId LONG)";
	public static final String TABLE_SQL_DROP = "drop table EDFunctionEmployee";
	public static final String ORDER_BY_JPQL = " ORDER BY edFunctionEmployee.functionId ASC, edFunctionEmployee.employeeId ASC";
	public static final String ORDER_BY_SQL = " ORDER BY EDFunctionEmployee.functionId ASC, EDFunctionEmployee.employeeId ASC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.vportal.portlet.edirectory.model.EDFunctionEmployee"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.vportal.portlet.edirectory.model.EDFunctionEmployee"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.vportal.portlet.edirectory.model.EDFunctionEmployee"),
			true);
	public static long EMPLOYEEID_COLUMN_BITMASK = 1L;
	public static long FUNCTIONID_COLUMN_BITMASK = 2L;
	public static long UUID_COLUMN_BITMASK = 4L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static EDFunctionEmployee toModel(EDFunctionEmployeeSoap soapModel) {
		EDFunctionEmployee model = new EDFunctionEmployeeImpl();

		model.setUuid(soapModel.getUuid());
		model.setId(soapModel.getId());
		model.setFunctionId(soapModel.getFunctionId());
		model.setEmployeeId(soapModel.getEmployeeId());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<EDFunctionEmployee> toModels(
		EDFunctionEmployeeSoap[] soapModels) {
		List<EDFunctionEmployee> models = new ArrayList<EDFunctionEmployee>(soapModels.length);

		for (EDFunctionEmployeeSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.vportal.portlet.edirectory.model.EDFunctionEmployee"));

	public EDFunctionEmployeeModelImpl() {
	}

	public long getPrimaryKey() {
		return _id;
	}

	public void setPrimaryKey(long primaryKey) {
		setId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_id);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return EDFunctionEmployee.class;
	}

	public String getModelClassName() {
		return EDFunctionEmployee.class.getName();
	}

	@JSON
	public String getUuid() {
		if (_uuid == null) {
			return StringPool.BLANK;
		}
		else {
			return _uuid;
		}
	}

	public void setUuid(String uuid) {
		if (_originalUuid == null) {
			_originalUuid = _uuid;
		}

		_uuid = uuid;
	}

	public String getOriginalUuid() {
		return GetterUtil.getString(_originalUuid);
	}

	@JSON
	public long getId() {
		return _id;
	}

	public void setId(long id) {
		_id = id;
	}

	@JSON
	public long getFunctionId() {
		return _functionId;
	}

	public void setFunctionId(long functionId) {
		_columnBitmask = -1L;

		if (!_setOriginalFunctionId) {
			_setOriginalFunctionId = true;

			_originalFunctionId = _functionId;
		}

		_functionId = functionId;
	}

	public long getOriginalFunctionId() {
		return _originalFunctionId;
	}

	@JSON
	public long getEmployeeId() {
		return _employeeId;
	}

	public void setEmployeeId(long employeeId) {
		_columnBitmask = -1L;

		if (!_setOriginalEmployeeId) {
			_setOriginalEmployeeId = true;

			_originalEmployeeId = _employeeId;
		}

		_employeeId = employeeId;
	}

	public long getOriginalEmployeeId() {
		return _originalEmployeeId;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public EDFunctionEmployee toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (EDFunctionEmployee)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
					EDFunctionEmployee.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	@Override
	public Object clone() {
		EDFunctionEmployeeImpl edFunctionEmployeeImpl = new EDFunctionEmployeeImpl();

		edFunctionEmployeeImpl.setUuid(getUuid());
		edFunctionEmployeeImpl.setId(getId());
		edFunctionEmployeeImpl.setFunctionId(getFunctionId());
		edFunctionEmployeeImpl.setEmployeeId(getEmployeeId());

		edFunctionEmployeeImpl.resetOriginalValues();

		return edFunctionEmployeeImpl;
	}

	public int compareTo(EDFunctionEmployee edFunctionEmployee) {
		int value = 0;

		if (getFunctionId() < edFunctionEmployee.getFunctionId()) {
			value = -1;
		}
		else if (getFunctionId() > edFunctionEmployee.getFunctionId()) {
			value = 1;
		}
		else {
			value = 0;
		}

		if (value != 0) {
			return value;
		}

		if (getEmployeeId() < edFunctionEmployee.getEmployeeId()) {
			value = -1;
		}
		else if (getEmployeeId() > edFunctionEmployee.getEmployeeId()) {
			value = 1;
		}
		else {
			value = 0;
		}

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		EDFunctionEmployee edFunctionEmployee = null;

		try {
			edFunctionEmployee = (EDFunctionEmployee)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = edFunctionEmployee.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		EDFunctionEmployeeModelImpl edFunctionEmployeeModelImpl = this;

		edFunctionEmployeeModelImpl._originalUuid = edFunctionEmployeeModelImpl._uuid;

		edFunctionEmployeeModelImpl._originalFunctionId = edFunctionEmployeeModelImpl._functionId;

		edFunctionEmployeeModelImpl._setOriginalFunctionId = false;

		edFunctionEmployeeModelImpl._originalEmployeeId = edFunctionEmployeeModelImpl._employeeId;

		edFunctionEmployeeModelImpl._setOriginalEmployeeId = false;

		edFunctionEmployeeModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<EDFunctionEmployee> toCacheModel() {
		EDFunctionEmployeeCacheModel edFunctionEmployeeCacheModel = new EDFunctionEmployeeCacheModel();

		edFunctionEmployeeCacheModel.uuid = getUuid();

		String uuid = edFunctionEmployeeCacheModel.uuid;

		if ((uuid != null) && (uuid.length() == 0)) {
			edFunctionEmployeeCacheModel.uuid = null;
		}

		edFunctionEmployeeCacheModel.id = getId();

		edFunctionEmployeeCacheModel.functionId = getFunctionId();

		edFunctionEmployeeCacheModel.employeeId = getEmployeeId();

		return edFunctionEmployeeCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(9);

		sb.append("{uuid=");
		sb.append(getUuid());
		sb.append(", id=");
		sb.append(getId());
		sb.append(", functionId=");
		sb.append(getFunctionId());
		sb.append(", employeeId=");
		sb.append(getEmployeeId());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(16);

		sb.append("<model><model-name>");
		sb.append("com.vportal.portlet.edirectory.model.EDFunctionEmployee");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>uuid</column-name><column-value><![CDATA[");
		sb.append(getUuid());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>id</column-name><column-value><![CDATA[");
		sb.append(getId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>functionId</column-name><column-value><![CDATA[");
		sb.append(getFunctionId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>employeeId</column-name><column-value><![CDATA[");
		sb.append(getEmployeeId());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = EDFunctionEmployee.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			EDFunctionEmployee.class
		};
	private String _uuid;
	private String _originalUuid;
	private long _id;
	private long _functionId;
	private long _originalFunctionId;
	private boolean _setOriginalFunctionId;
	private long _employeeId;
	private long _originalEmployeeId;
	private boolean _setOriginalEmployeeId;
	private transient ExpandoBridge _expandoBridge;
	private long _columnBitmask;
	private EDFunctionEmployee _escapedModelProxy;
}